package com.weng.platform.platform.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.weng.framework.core.model.ResponseData;
import com.weng.framework.dao.mybatis.model.page.PageModel;
import com.weng.framework.dao.mybatis.service.BaseServiceImpl;
import com.weng.platform.platform.entity.TeamMemberRel;
import com.weng.platform.platform.mapper.TeamMemberRelMapper;
import com.weng.platform.platform.service.ITeamMemberRelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.Arrays;


/**
 * 团队成员关联 服务实现类
 *
 * @author weng
 * @date 2021-01-15 17:18:49
 *
 */ 
@Slf4j
@Service
public class TeamMemberRelServiceImpl extends BaseServiceImpl<TeamMemberRelMapper, TeamMemberRel> implements ITeamMemberRelService {
	@Autowired
	private TeamMemberRelMapper teamMemberRelMapper;
	

	/**
	 * 分页查询团队成员关联
	 * @return
	 */
	@Override
	public IPage<TeamMemberRel> list(Integer pageNo,Integer pageSize) {
		QueryWrapper<TeamMemberRel> qw = new QueryWrapper<>();
		IPage<TeamMemberRel> page = new PageModel<>(pageNo,pageSize);
		return teamMemberRelMapper.selectPage(page,qw);
	}


	/**
	 * 获取单个团队成员关联
	 * @param id
	 * @return
	 */
	@Override
	public TeamMemberRel getById(Serializable id) {
		return super.getById(id);
	}

	/**
	 * 新增单个团队成员关联
	 * @param teamMemberRel
	 * @return
	 */
	@Override
	public TeamMemberRel add(TeamMemberRel teamMemberRel)  {
		
		teamMemberRelMapper.insert(teamMemberRel);
		return teamMemberRel;
	}

	/**
	 * 更新单个团队成员关联
	 * @param teamMemberRel
	 * @return
	 * @
	 */
	@Override
	public int update(TeamMemberRel teamMemberRel)  {
		
		return teamMemberRelMapper.updateById(teamMemberRel);

	}


	@Override
	public ResponseData removeByIds(String ids) {
		String[] teamMemberRelIds = ids.split(",");
		boolean flag = this.removeByIds(Arrays.asList(teamMemberRelIds));
		if (flag) {
			return ResponseData.success();
		} else {
			return ResponseData.success();
		}
	}

}
